﻿using SD.OpcProxy.Domain.Entities;
using SD.Toolkits.EntityFramework.Extensions;
using System.Data.Entity.ModelConfiguration;

namespace SD.OpcProxy.Repository.EntityConfigurations
{
    /// <summary>
    /// OPC服务器实体映射配置
    /// </summary>
    public class OpcServerConfig : EntityTypeConfiguration<OpcServer>
    {
        /// <summary>
        /// 构造器
        /// </summary>
        public OpcServerConfig()
        {
            //设置编号长度
            this.Property(opcServer => opcServer.Number).HasMaxLength(64);

            //设置唯一键索引
            this.HasIndex("IX_Number", IndexType.Unique, table => table.Property(opcServer => opcServer.Number));
        }
    }
}
